package com.ybf.user.dal.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ybf.user.dal.entity.query.AdminDepartmentDO;
import com.ybf.user.dal.mapper.AdminDepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

@Component
public class AdminDepartmentManager extends ServiceImpl<AdminDepartmentMapper, AdminDepartmentDO> {


    @Autowired
    private AdminDepartmentMapper adminDepartmentMapper;

    /**
     * 获取列表 by 科室id
     *
     * @author 向南
     * @date 15:44 2023/7/7
     * @param: departmentId
     **/
    public List<AdminDepartmentDO> selectByDepartment(Long departmentId) {
        if (Objects.isNull(departmentId)) {
            return Collections.emptyList();
        }
        return adminDepartmentMapper.selectList(new LambdaQueryWrapper<AdminDepartmentDO>()
                .eq(AdminDepartmentDO::getDepartmentId, departmentId));
    }

    /**
     * 获取列表 by adminId
     *
     * @author 向南
     * @date 15:05 2023/7/20
     * @param: adminId
     **/
    public List<AdminDepartmentDO> selectByAdminId(Long adminId) {
        if (Objects.isNull(adminId)) {
            return Collections.emptyList();
        }
        return adminDepartmentMapper.selectList(new LambdaQueryWrapper<AdminDepartmentDO>()
                .eq(AdminDepartmentDO::getAdminId, adminId));
    }

    /**
     * 获取列表
     *
     * @author 向南
     * @date 11:57 2023/7/28
     * @param: adminIds
     **/
    public List<AdminDepartmentDO> selectInAdminIds(List<Long> adminIds) {
        if (CollectionUtils.isEmpty(adminIds)) {
            return Collections.emptyList();
        }
        return adminDepartmentMapper.selectList(new LambdaQueryWrapper<AdminDepartmentDO>()
                .in(AdminDepartmentDO::getAdminId, adminIds));
    }

    /**
     * 获取列表 - 数据权限
     *
     * @author 向南
     * @date 17:58 2023/7/28
     **/
    public List<AdminDepartmentDO> selectByDataPermission() {
        return adminDepartmentMapper.selectList(null);
    }
}
